79
Build Your Own Remote Control
79
function called GetAsyncKeyState that is available for use but has to be declared
upfront (see step 1 code). The code below covers some of the basic navigations that
can be done by the user near the laptop, without using the smartphone. The letter “N”,
Right or Down keys take you to next slide. The letter “P”, Up, or Left keys take you
to the previous slide. The “X” key is to exit the program.
STEP 3
Sub ManualInterrupt()
Const VK_CONTROL = &H11, VK_LEFT = &H25, VK_UP = &H26, VK_
RIGHT = &H27, VK_DOWN = &H28
Const VK_0 = &H30, VK_1 = &H31, VK_2 = &H32, VK_3 = &H33, VK_4 = &H34
Const VK_5 = &H35, VK_6 = &H36, VK_7 = &H37, VK_8 = &H38, VK_9 = &H39
Const VK_A = &H41, VK_B = &H42, VK_C = &H43, VK_D = &H44, VK_
E = &H45
Const VK_F = &H46, VK_G = &H47, VK_H = &H48, VK_I = &H49, VK_J = &H4A
Const VK_K = &H4B, VK_L = &H4C, VK_M = &H4D, VK_N = &H4E, VK_
O = &H4F
Const VK_P = &H50, VK_Q = &H51, VK_R = &H52, VK_S = &H53, VK_T = &H54
Const VK_U = &H55, VK_V = &H56, VK_W = &H57, VK_X = &H58, VK_
Y = &H59, VK_Z = &H5A
Const VK_ENTER = &HD
If GetAsyncKeyState(VK_X) <> 0 Then
‘ MsgBox (“forced exit”)
ForcedExit = 1
MsgBox (“Forced”)
End If
If GetAsyncKeyState(VK_DOWN) <> 0 Then
NextSlide
End If
If GetAsyncKeyState(VK_RIGHT) <> 0 Then
NextSlide
End If
If GetAsyncKeyState(VK_UP) <> 0 Then
PreviousSlide
End If
If GetAsyncKeyState(VK_LEFT) <> 0 Then
PreviousSlide
End If
If GetAsyncKeyState(VK_P) <> 0 Then
PreviousSlide
End If
If GetAsyncKeyState(VK_N) <> 0 Then
NextSlide
End If
End Sub
Note—VBA code in powerpoint is slightly different than in excel—some com
mands and functions used in excel do not work in powerpoint.